<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
            <%@page import="java.sql.*" %><!-- 数据库操作需要 -->  
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>用车记录</title>
    <link rel="stylesheet" href="UC_style.css">
    <style>
        #header2 {
            height: 40px;
            background: white;
        }

        .main {
            width: 100%;
            height: 800px;
            background: RGB(239,239,239);
            float: left;
        }

        h3 {
            text-align: center;
            margin-top: 10px;
            margin-bottom: 10px;
            color:black;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
        }

        th, td {
            text-align: left;
            padding: 10px;
            border-bottom: 1px solid #ddd;
            text-align: center;
        }
        th {
            background-color: #ddd;
        }
        .a1{
			font-size:13px;
		}
		.a1:hover {
		    color: blue;
		}
    </style>
</head>
<body>
<%
	String addok=(String)request.getAttribute("addok");
	String EmpID=(String)session.getAttribute("EmpID"); 
	if(addok!=null&&addok.equals("1"))
	{%>
	<script type="text/javascript">
		alert("删除成功！");
	</script>
	<% }	
	if(addok!=null&&addok.equals("2"))
	{%>
	<script type="text/javascript">
		alert("修改成功！");
	</script>
	<% }
	//第一个java代码段查询数据
	try{
		Class.forName("org.h2.Driver");//加载驱动
	} catch (ClassNotFoundException e) {
		e.printStackTrace();
		return;
	}
	String url="jdbc:h2:d:/CompanyCar/temp/mydbtest";
	Connection conn=null;

//数据库连接与查询过程中可能会引发sql异常
try {
	//获取数据库连接(url,username,password)			
	conn = DriverManager.getConnection(url,"sa","");
	//准备执行数据库查询
	String sql="select * from EmployeeCarInfo where EmpID='"+EmpID+"'";
	//准备SQL执行;
	Statement stmt=conn.createStatement();
	//执行数据库查询，获取结果集
	ResultSet rs=stmt.executeQuery(sql);
	

%>	
    <div class="main">
        <div id="header2">
            <img src="img/frist.png" alt="Big Boat" width="30" height="30" style=" vertical-align: middle;">
            乘客用车管理 > 用车记录
        </div>
        <h3>用车记录</h3>
        <table>
            <thead>
                <tr>
                    <th>单号</th>
                    <th>司机姓名</th>
                    <th>车牌号</th>
                    <th>开始日期</th>
                    <th>结束日期</th>
                    <th>起始地点</th>
                    <th>前往地点</th>
                    <th>乘车人数</th>
                    <th>司机电话</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                <%	int count=0;
				while(rs!=null && rs.next())
				{ 
					String RequestID=rs.getString("RequestID");
					String UseTime=rs.getString("UseTime");
					UseTime=UseTime.replace("T", " ");
					String ReturnTime=rs.getString("ReturnTime");
					ReturnTime=ReturnTime.replace("T", " ");
					//String Status=rs.getString("Status");
					//if(!Status.equals("审核未通过"))
							//continue;
				%>
					<tr  >
						<td>
							<%=RequestID %>
						</td>
						<td>
							<%=rs.getString("Dname") %>
						</td>
						<td>
							<%=rs.getString("license_plate") %>
						</td>
						<td>
							<%=UseTime %>
						</td >
						
						<td>
							<%=ReturnTime %>
						</td>
						<td>
							<%=rs.getString("origin")%>
						</td>					
						<td>
							<%=rs.getString("goPlace") %>
						</td>	
						<td>
							<%=rs.getInt("UsersNum")%>
						</td>					
						<td>
							<%=rs.getString("Dphone") %>
						</td>					
						<td>
							
							<%String editURL="C-jdbc-editcheckList.jsp?RequestID="+RequestID; %>
							<a class="a1" href=<%=editURL %>>重新申请</a>
							<%String deleteURL="C-jdbc-AdminReturn.jsp?RequestID="+RequestID+"&staff=1"; %>
							<a class="a1" style="color:red" href=<%=deleteURL %>>取消申请</a>
						</td>
					</tr>
					<%} %>
            </tbody>
        </table>
    </div>
    
<%
	//关闭表达式对象
	stmt.close();			
	//关闭数据库			
	conn.close();			
	
} catch (SQLException e) {
	e.printStackTrace();
} finally{
	//防止数据库未正常关闭
	try{
		if (conn!=null && (!conn.isClosed())){
			conn.close();
		}
	}catch(SQLException e){
		e.printStackTrace();
	}
}
%>
</body>
</html>